<?php
// Main index
class PersonAction extends CommonAdminAction {
	public function _initialize() {
		parent::_initialize();
		$this->setNav(array(
		array("个人管理", __URL__),
		));
	}
	/**
	 * 新增操作
	 * @access public
	 * @return void
	 * @throws ThinkExecption
	 */
	public function create() {
		// 公司下拉框
		$companyList = $this->companyList();
		$this->assign('companyList', $companyList);
		$this->display();
	}

	/**
	 * 更新操作
	 * @access public
	 * @return void
	 * @throws ThinkExecption
	 */
	function update() {
		$vo = $this->_update();
		if (!$vo) {
			$this->error("未找到更改的目标");
		}

		// 公司下拉框
		$companyList = $this->companyList();

		$this->assign('companyList', $companyList);

		$this->assign('vo', $vo);
		$this->display();
	}

	/**
	 * 更新: 根据主键取得项目
	 * @access public
	 * @return void
	 * @throws ThinkExecption
	 */
    protected function _update() {
        $name = $this->_getDBName();
        $model = M($name);
        $id = $_REQUEST [$model->getPk()];
        return $model->where(array($model->getPk()=>$id))->find();
    }
    

	protected function companyList() {
		$company = M('company');
		$list = $company->select();
		return $list;
	}

}
?>